<? /* license

BilugCMS (http://www.bilug.it) - Content Management System for dynamic web sites
Copyright (C) 2005-2008  Federico Villa and Alessio Loro Piana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For reference, contact bilugcms@vilnet.it


license */ ?>

<?

function vismenu($id,$tip,$space)
{
	$query="SELECT id, titolo, tipo, idpadre, link, posizione FROM menutipo WHERE tipo='$tip' AND idpadre=$id ORDER BY posizione";
	$risultato=mysql_query($query);
	$row=mysql_num_rows($risultato);
	//$voci=mysql_fetch_row($risultato);
	
	if(!$row)
	{
		return "no";
	}
	else
	{	echo"<br><br>";
		
		$space++;
		echo"<ul>\n";	
		while($voci=mysql_fetch_row($risultato))
		{
			for($i=0;$i<$space;$i++)
			{
				echo"<div class=\"float20\">&nbsp;</div>";
			}
			echo "<div class=\"evidenzia\"><li>
			<div class=\"float20\">$voci[2]</div>
			<div class=\"float160\">$voci[1]</div>
			<div class=\"float70\"><img src=\"./img/del.png\" id=\"ico\" /><a title=\"|Elimina Argomento\" href=\"area.php?pag=delete.php&id=$voci[0]&from=elenco_menu_new.php\">Elimina</a></div>
			<div class=\"float70\"><img src=\"./img/mod.png\" id=\"ico\" /><a title=\"|Modifica Argomento\" href=\"area.php?pag=insert_menu_new.php&amp;id=$voci[0]\">Modifica</a></div>
			<div class=\"float70\"><img src=\"./img/su.png\" id=\"ico\" /><a title=\"|up\" href=\"area.php?pag=up_down_menu.php&dir=D&id=$voci[0]\">alza</a></div>
			<div class=\"float70\"><img src=\"./img/giu.png\" id=\"ico\" /><a title=\"|down\" href=\"area.php?pag=up_down_menu.php&dir=U&id=$voci[0]\">abbassa</a></div>";
			$car=substr($voci[2],0,1);
			//echo "$car";
			if($car!="a")
			{
				echo"
					<div class=\"float100\"><img src=\"./img/sot.png\" id=\"ico\" /><a title=\"|Aggiungi un Sottomenu\" href=\"area.php?pag=insert_sotmenu.php&amp;tipo=$tip&amp;idpadre=$voci[0]\">Sottomenu</a></div>";
			}		
				$funz=vismenu($voci[0],$voci[2],$space);
			if($funz=="no")
			{
				echo"
					<div class=\"float70\"><img src=\"./img/lnk.png\" id=\"ico\" /><a title=\"|Aggiungi un Link\" href=\"area.php?pag=insert_sotmenu_link.php&amp;id=$voci[0]\">Link</a></div>
					<div class=\"float160\">$voci[4]</div>";
			}
			echo"</li></div><br><br>";
		}
		echo"</li>\n</ul>\n";
		return "ok";
	} 
}






require_once("auth.php");
$errore=$_GET["errore"];
echo"<h1>$errore</h1>";
echo "<div class=\"contenitore\"><div class=\"azzerafloat\"></div>";
echo " tipo = ax significa according &nbsp;&nbsp;&nbsp; tipo = tx significa tendina (solo orizzontale alto)";		
echo "</div><br>";

echo"<div class=\"contenitore\"><div class=\"azzerafloat\"></div>";

$query = "SELECT tipo FROM menutipo GROUP BY tipo";
$ris=mysql_query($query);
$row=mysql_num_rows($ris);

echo "<ul>";
if($row>0)
{
while($tipo=mysql_fetch_array($ris))
{	
	$queryp = "SELECT id, titolo, tipo, idpadre, link, posizione FROM menutipo WHERE tipo='$tipo[0]' AND idpadre=0 ORDER BY posizione";
	$princ=mysql_query($queryp);
	$row1=mysql_num_rows($princ);
	
		while($principali=mysql_fetch_row($princ))
		{
			echo "<div class=\"evidenzia\"><li>
			<div class=\"float20\">$principali[2]</div>
			<div class=\"float160\">$principali[1]</div>
			<div class=\"float70\"><img src=\"./img/del.png\" id=\"ico\" /><a title=\"|Elimina Argomento\" href=\"area.php?pag=delete.php&id=$principali[0]&from=elenco_menu_new.php\">Elimina</a></div>
			<div class=\"float70\"><img src=\"./img/mod.png\" id=\"ico\" /><a title=\"|Modifica Argomento\" href=\"area.php?pag=insert_menu_new.php&amp;id=$principali[0]\">Modifica</a></div>
			<div class=\"float70\"><img src=\"./img/su.png\" id=\"ico\" /><a title=\"|up\" href=\"area.php?pag=up_down_menu.php&dir=D&id=$principali[0]\">alza</a></div>
			<div class=\"float70\"><img src=\"./img/giu.png\" id=\"ico\" /><a title=\"|down\" href=\"area.php?pag=up_down_menu.php&dir=U&id=$principali[0]\">abbassa</a></div>
			<div class=\"float100\"><img src=\"./img/sot.png\" id=\"ico\" /><a title=\"|Aggiungi un Sottomenu\" href=\"area.php?pag=insert_sotmenu.php&amp;tipo=$tipo[0]&amp;idpadre=$principali[0]\">Sottomenu</a></div>";
				$funz=vismenu($principali[0],$tipo[0],1);
			if($funz=="no")
			{
				echo"
					<div class=\"float70\"><img src=\"./img/lnk.png\" id=\"ico\" /><a title=\"|Aggiungi un Link\" href=\"area.php?pag=insert_sotmenu_link.php&amp;id=$principali[0]\">Link</a></div>
					<div class=\"float230\">$principali[4]</div>";
			}
			echo"</li></div><br><br>";
		}
	
}
echo "</ul>";
echo "</div>";
}
else
{
echo "<p>Tabella vuota</p>";
}
echo "<br>";

echo "<div class=\"contenitore\"><div class=\"azzerafloat\"></div>
		<div class=\"evidenzia\">
			
				<img src=\"./img/add.png\" id=\"ico\" /> <a href=\"area.php?pag=insert_menu_new.php\">Nuovo menu</a>
			
		</div>
	  </div>";
		

?>
